package com.demo.project_template.controller;

import com.demo.project_template.entity.SysMenu;
import com.demo.project_template.service.SysMenuService;
import com.demo.project_template.vo.request.sys.SysMenuRequestVO;
import com.demo.project_template.vo.response.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author 杨玉龙
 * @since 2024-01-03 20:32:03
 */

@Api(tags = "后台菜单模块")
@RestController
@RequestMapping("/sysMenu")
public class SysMenuController {
    @Resource
    private SysMenuService sysMenuService;

    @PreAuthorize("@ex.hasAuthority('sys:user:list')")
    @ApiOperation("查询所有系统菜单")
    @GetMapping("/listMenu")
    public R<List<SysMenu>> listMenu(){
        return R.success(sysMenuService.list());
    }

    @ApiOperation("创建系统菜单")
    @PostMapping("/createSysMenu")
    public R<?> createSysMenu(@RequestBody SysMenuRequestVO sysMenuRequestVO){
        sysMenuService.createSysMenu(sysMenuRequestVO);
        return R.success();
    }
}
